var Code = new Pearlsen.BaseList({
	gridId:'codeGrid',
	module:'码表',
	modulePath:'/pages/sysmgr/code/',
	moduleName:'Code',
	idProperty:'ID',
	nameProperty:'CODE_TEXT',
	dataSetHandler:'CodeDataSetHandler',
	queryHandler:'CodeQueryHandler',
	advSearchId:'aaaaaa',
	//加载页面
	loadCurrent:function(){
//		var tree = Ext.getCmp("categoryTree");
//		var store = tree.getStore();
//		var data = store.find("id","");
//		alert(data);
	},
	//重写
	add:function(){
		var tree = Ext.getCmp("catalogTree");
		var node = tree.getSelectionModel().getSelection();
		if( node && node.length > 0 ){
			var url = this.getAddUrl();
			url = url+"?codeType={0}&codeDesc={1}";
			url = url.format(node[0].data['id'],node[0].data['text']);
			var tabId = this.createTabId("add");
			parent.MainTab.addTab(tabId,"新增"+this.module,url);
		}else{
			Pearlsen.Utils.showInfoMsg('请先选中类型');
		}
	},
	edit:function() {
		var grid = Ext.getCmp("codeGrid");
		var row = grid.getSelectionModel().getSelection();
		if( row && row.length > 0 ){
			var tabId = this.createTabId("edit");
			parent.MainTab.addTab(tabId,"编辑"+this.module,this.getEditUrl());
		}else{
			Pearlsen.Utils.showInfoMsg('请先选中要编辑的代码');
		}
	},
	_delOne:function(){
     	var me = this;
		var record = this.getSelectedOne();
     	if( Ext.isEmpty(record) ){
     		return ;
     	}
        Ext.MessageBox.confirm('删除提示', '确定要删除【'+record.data[this.nameProperty]+'】吗?',function(btn){
        	if(btn=='yes'){
        		if( !me.dataSetHandler ){
        			throw new Error("未设置没有指定dataSetHandler");
        		}
         	 	var ds=new DataSet(me.dataSetHandler,me.moduleName+"_dataset");
         	 	ds.setHandlerMethod(me.deleteMethod);
     			ds.addCondition("objId",record.data[me.idProperty]);
     			ds.execute(function(result){
     				if( result.success ){
     					me.getGrid().getStore().remove(record);
     				}else{
     					Pearlsen.Utils.showErrorMsg("出错了,原因:"+result.message);
     				}
     			});
         	 }
		});
	},
	refreshGrid:function(){
		//this.getGrid().getStore().load();
	},
	//	
	quickSearch:function(){
		alert("1");	
	},
	//树单击事件
	treeItemclick:function(tree,model){
		var me = Code;
		var query=new Query('CodeQueryHandler','code_dataset');
		query.setHandlerMethod("getCodeList");
		query.addCondition("codeType",model.get('id'));
		query.setCompletedFun(me.afterLoadCodeList);
		var ds=query.load();
		//Ext.getCmp("codeGrid").getStore().loadData(ds.record);
	},
	afterLoadCodeList:function(success,dataset,response, opts){
		if(success){
			//if( dataset && !Ext.isEmpty(dataset.record)){
				Ext.getCmp("codeGrid").getStore().loadData(dataset.record);
			//}
		}
	}
});